﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Knights.Recursos
{
    class Cubo : Modelo
    {
        private float ladoMitad;
        private Vector3 normal;

        public Cubo(int lado)
        {
            ladoMitad = lado / 2;
            normal = Vector3.Up;

            Inicializar();
        }

        public override void Inicializar()  //refactorizar
        {
            //lado techo
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, ladoMitad, ladoMitad), normal, new Vector2(0, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, ladoMitad, -ladoMitad), normal, new Vector2(0, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, ladoMitad, -ladoMitad), normal, new Vector2(1, 1)));

            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, ladoMitad, -ladoMitad), normal, new Vector2(1, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, ladoMitad, ladoMitad), normal, new Vector2(1, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, ladoMitad, ladoMitad), normal, new Vector2(0, 0)));

            ////lado piso
            normal = new Vector3(0, -1, 0);
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, -ladoMitad, -ladoMitad), normal, new Vector2(0, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, -ladoMitad, ladoMitad), normal, new Vector2(0, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, -ladoMitad, -ladoMitad), normal, new Vector2(1, 1)));

            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, -ladoMitad, -ladoMitad), normal, new Vector2(1, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, -ladoMitad, ladoMitad), normal, new Vector2(0, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, -ladoMitad, ladoMitad), normal, new Vector2(1, 0)));

            //lado frente
            normal = new Vector3(1, 0, 0);
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, -ladoMitad, ladoMitad), normal, new Vector2(0, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, ladoMitad, ladoMitad), normal, new Vector2(0, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, -ladoMitad, -ladoMitad), normal, new Vector2(1, 1)));

            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, -ladoMitad, -ladoMitad), normal, new Vector2(1, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, ladoMitad, ladoMitad), normal, new Vector2(0, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, ladoMitad, -ladoMitad), normal, new Vector2(1, 0)));

            ////lado detras
            normal = new Vector3(-1, 0, 0);
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, ladoMitad, ladoMitad), normal, new Vector2(0, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, -ladoMitad, ladoMitad), normal, new Vector2(0, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, -ladoMitad, -ladoMitad), normal, new Vector2(1, 1)));

            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, -ladoMitad, -ladoMitad), normal, new Vector2(1, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, ladoMitad, -ladoMitad), normal, new Vector2(1, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, ladoMitad, ladoMitad), normal, new Vector2(0, 0)));

            //lado derecha
            normal = new Vector3(0, 0, 1);
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, -ladoMitad, ladoMitad), normal, new Vector2(0, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, ladoMitad, ladoMitad), normal, new Vector2(0, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, -ladoMitad, ladoMitad), normal, new Vector2(1, 1)));

            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, -ladoMitad, ladoMitad), normal, new Vector2(1, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, ladoMitad, ladoMitad), normal, new Vector2(0, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, ladoMitad, ladoMitad), normal, new Vector2(1, 0)));

            //lado izquierda
            normal = new Vector3(0, 0, -1);
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, ladoMitad, -ladoMitad), normal, new Vector2(0, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, -ladoMitad, -ladoMitad), normal, new Vector2(0, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, -ladoMitad, -ladoMitad), normal, new Vector2(1, 1)));

            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, -ladoMitad, -ladoMitad), normal, new Vector2(1, 1)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(ladoMitad, ladoMitad, -ladoMitad), normal, new Vector2(1, 0)));
            vertices.Add(new VertexPositionNormalTexture(new Vector3(-ladoMitad, ladoMitad, -ladoMitad), normal, new Vector2(0, 0)));

            base.Inicializar();
        }
    }
}
